package com.pubinfo.passbook.data.quartz.task;

import com.pubinfo.passbook.common.service.contract.TContractSyncService;
import lombok.extern.slf4j.Slf4j;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.Job;
import org.quartz.JobDataMap;
import org.quartz.JobExecutionContext;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 同步合同信息
 */
@Slf4j
@Component
@DisallowConcurrentExecution
public class SyncContractJob implements Job {

    @Resource
    private TContractSyncService contractSyncService;
  
  @Override
    public void execute(JobExecutionContext context) {
      //同步合同
  
      JobDataMap dataMap = context.getJobDetail().getJobDataMap();
      String taskId = dataMap.getString("task-id");
    
    try {
      contractSyncService.syncContract(taskId);
      
      //同步项目
      contractSyncService.syncContractProject();
      
      //同步项目成本
      contractSyncService.syncContractCostItems();
      //同步未清项目
      contractSyncService.syncProjectNotClear();
    } catch (Exception e) {
      e.printStackTrace();
      
    }
    
  }

}